#pragma once
#include <iostream>
#include <string>
#include <stdio.h>
#include <pthread.h>
#include <vector>
#include <queue>
#include <unistd.h>

typedef void*(*func_t)(void* args);

class ThreadData
{
public:
	std::string _name;
	void* _args;
};


class Thread
{
public:
	Thread(func_t callback, void* args, int ThreadNo)
		:_func(callback)
	{
		char buffer[64];
		snprintf(buffer, sizeof(buffer), "thread : %d", ThreadNo);
		_td._name = buffer;
		_td._args = args;
	}

	void start()
	{
		pthread_create(&_tid, nullptr, _func, &_td);
	}

	std::string getName()
	{
		return _td._name;
	}

	~Thread()
	{
		pthread_join(_tid, nullptr);
	}

private:
	pthread_t _tid;
	func_t _func;
	ThreadData _td;
};